package com.tjbank.cssys.mybatis.impl;

import com.tjbank.cssys.mybatis.IamTenantDao;
import com.tjbank.cssys.mybatis.entity.IamTenant;
import com.tjbank.cssys.mybatis.entity.IamTenantKey;
import com.tjbank.cssys.mybatis.mapper.IamTenantMapper;
import com.tjbank.cssys.mybatis.sqlbuilder.IamTenantSqlBuilder;
import java.util.List;
import javax.annotation.Resource;

import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * IamTenantDaoImpl
 * 
 * @author PG(Auto Generator)
 * @version V2.0
 */
@Service
public class IamTenantDaoImpl implements IamTenantDao {
    @Resource
    private IamTenantMapper iamTenantMapper;

    public IamTenantDaoImpl() {
        super();
    }

    @Override
    public List<IamTenant> selectListBySqlBuilderWithBLOBs(IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        return iamTenantMapper.selectBySqlBuilderWithBLOBs(iamTenantSqlBuilder);
    }

    @Override
    public List<IamTenant> selectListBySqlBuilder(IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        return iamTenantMapper.selectBySqlBuilder(iamTenantSqlBuilder);
    }

    @Override
    public IamTenant selectBySqlBuilderWithBLOBs(IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        List<IamTenant> listIamTenants = selectListBySqlBuilderWithBLOBs(iamTenantSqlBuilder);
        if (listIamTenants == null || listIamTenants.isEmpty()) {
            return null;
        } else if (listIamTenants.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamTenants.get(0);
    }

    @Override
    public IamTenant selectBySqlBuilder(IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        List<IamTenant> listIamTenants = selectListBySqlBuilder(iamTenantSqlBuilder);
        if (listIamTenants == null || listIamTenants.isEmpty()) {
            return null;
        } else if (listIamTenants.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamTenants.get(0);
    }

    @Override
    public IamTenant selectByPrimaryKey(IamTenantKey iamTenantKey) throws RuntimeException {
        return iamTenantMapper.selectByPrimaryKey(iamTenantKey);
    }

    @Override
    public long countBySqlBuilder(IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        return iamTenantMapper.countBySqlBuilder(iamTenantSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insert(IamTenant iamTenant) throws RuntimeException {
        return iamTenantMapper.insert(iamTenant);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insertUseBatch(List<IamTenant> listIamTenants) throws RuntimeException {
        return iamTenantMapper.insertUseBatch(listIamTenants);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilder(IamTenant iamTenant, IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        iamTenantSqlBuilder.setUpdateObject(iamTenant);
        return iamTenantMapper.updateBySqlBuilder(iamTenantSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilderSelective(IamTenant iamTenant, IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        iamTenantSqlBuilder.setUpdateObject(iamTenant);
        return iamTenantMapper.updateBySqlBuilderSelective(iamTenantSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKey(IamTenant iamTenant) throws RuntimeException {
        return iamTenantMapper.updateByPrimaryKey(iamTenant);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKeySelective(IamTenant iamTenant) throws RuntimeException {
        return iamTenantMapper.updateByPrimaryKeySelective(iamTenant);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteBySqlBuilder(IamTenantSqlBuilder iamTenantSqlBuilder) throws RuntimeException {
        return iamTenantMapper.deleteBySqlBuilder(iamTenantSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteByPrimaryKey(IamTenantKey iamTenantKey) throws RuntimeException {
        return iamTenantMapper.deleteByPrimaryKey(iamTenantKey);
    }
}